package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-09-19
 * Time: 18:24
 */
public class ThreadDemon8 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        System.out.println(thread.isAlive());//false,有对象，无pcb线程
        thread.start();//创建线程
        System.out.println(thread.isAlive());//true,有对象，有pcb
        Thread.sleep(5000);//main函数线程沉睡5s，此时Thread线程3s沉睡完了，thread线程结束，thread对象还在
        System.out.println(thread.isAlive());//false

    }

}
